import java.util.*;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * user:likai
 * Date:2023-04-19
 * Time:21:21
 */
class Solution{
    //错误
    public boolean isAnagram(String s, String t) {
        if(s.length()!=t.length()){
            return false;
        }
        Map<Character,Integer> s1=new HashMap<>();
        Map<Character,Integer> t1=new HashMap<>();
        for(int i=0;i<s.length();i++){
            char ch=s.charAt(i);
            if(s1.containsKey(ch)){
                s1.put(ch,s1.get(ch)+1);
            }else{
                s1.put(ch,1);
            }
        }
        for(int i=0;i<t.length();i++){
            char ch=t.charAt(i);
            if(t1.containsKey(ch)){
                t1.put(ch,t1.get(ch)+1);
            }else{
                t1.put(ch,1);
            }
        }
        for(Map.Entry<Character,Integer>map:s1.entrySet()){
            if(!t1.containsKey(map.getKey())||map.getValue()!=t1.get(map.getKey())){
                return false;
            }
        }
        return true;
    }
    public boolean isAnagram1(String s, String t) {
        int[] arr=new int[26];
        for(int i=0;i<s.length();i++){
            char ch=s.charAt(i);
            arr[ch-'a']++;
        }
        for(int i=0;i<t.length();i++){
            char ch=t.charAt(i);

            arr[ch-'a']--;
        }
        for(int i=0;i<arr.length;i++){
            if(arr[i]!=0){
                return false;
            }
        }
        return true;
    }
    public int[] intersection(int[] nums1, int[] nums2) {
        if(nums1==null||nums2==null){
            return null;
        }
        Set<Integer> set1=new HashSet<>();
        Set<Integer> set2=new HashSet<>();
        for(int i=0;i<nums1.length;i++){
            if(!set1.contains(nums1[i])){
                set1.add(nums1[i]);
            }
        }
        for(int i=0;i<nums2.length;i++){
            if(set1.contains(nums2[i])){
                set2.add(nums2[i]);
            }
        }
        int []arr=new int[set2.size()];
        int j=0;
        for(int i:set2){
            arr[j++]=i;
        }
        return arr;
    }
    public boolean isHappy(int n) {
        Set <Integer> set1=new HashSet<>();
        while(n!=1){
            n=number(n);
            if(set1.contains(n)){
                return false;
            }else{
                set1.add(n);
            }
        }
        return true;
    }
    public int number(int n){
        int sum=0;
        while(n>0){
            int x=n%10;
            sum+=x*x;
            n/=10;
        }
        return sum;
    }
    public int[] twoSum(int[] nums, int target) {
        int []arr=new int[2];
        for(int i=0;i<nums.length;i++){
            for(int j=i+1;j<nums.length;j++){
                if(nums[i]+nums[j]==target){
                    arr[0]=i;
                    arr[1]=j;
                    return arr;
                }
            }
        }
        return null;
    }
    public int fourSumCount(int[] nums1, int[] nums2, int[] nums3, int[] nums4) {

        //组装12,34
        HashMap<Integer,Integer> map1=two(nums1,nums2);
        HashMap<Integer,Integer> map2=two(nums3,nums4);
        int count=0;
        for(Map.Entry<Integer,Integer> imap:map1.entrySet()){
            for(Map.Entry<Integer,Integer> jmap:map2.entrySet()){
                int x=imap.getKey();
                int y=jmap.getKey();
                if(x+y==0){
                    count+=imap.getValue()*jmap.getValue();
                }
            }
        }
        return count;
    }
    public HashMap two(int []nums1,int []nums2){
        HashMap<Integer,Integer> map=new HashMap<>();

        for(int i=0;i<nums1.length;i++){
            for(int j=0;j<nums2.length;j++){
                int x=nums1[i]+nums2[j];
                if(map.containsKey(x)){
                    map.put(x,map.get(x)+1);
                }else{
                    map.put(x,1);
                }
            }
        }
        return map;
    }
    public boolean canConstruct(String ransomNote, String magazine) {
        HashMap<Character,Integer> map=new HashMap<>();
        for(int i=0;i<magazine.length();i++){
            char j=magazine.charAt(i);
            if(map.containsKey(j)){
                map.put(j,map.get(j)+1);
            }else{
                map.put(j,1);
            }
        }
        for(int i=0;i<ransomNote.length();i++){
            char j=ransomNote.charAt(i);
            if(map.containsKey(j)&&map.get(j)>0){
                map.put(j,map.get(j)-1);
            }else{
                return false;
            }
        }
        return true;
    }
}
public class Test {
    public static void main(String[] args) {
        int arr[]=new int[26];
    }
}
